<template>

    <el-menu :collapse="false" @select="changePage">
        <el-menu-item index="1">
            <template #title>
                <el-icon><house/></el-icon>
                <span>首页</span>
            </template>
        </el-menu-item>
        <el-menu-item index="2">
            <template #title>
                <el-icon><user/></el-icon>
                <span>友账本</span>
            </template>
        </el-menu-item>
        <el-sub-menu index="3">
            <template #title>
                <el-icon><set-up/></el-icon>
                <span>系统状态</span>
            </template>
            <!-- <el-menu-item index="3-1">
                <template #title>
                    <el-icon><stopwatch/></el-icon>
                    参数配置
                </template>
            </el-menu-item> -->
            <el-menu-item index="3-2">
                <template #title>
                    <el-icon><monitor/></el-icon>
                    节点信息
                </template>
            </el-menu-item>
        </el-sub-menu>
        <el-menu-item index="4">
            <template #title>
                <el-icon><postcard/></el-icon>
                <span>关于</span>
            </template>
        </el-menu-item>
      <el-menu-item index="5">
        <template #title>
          <el-icon><Guide /></el-icon>
          <span>留言板</span>
        </template>
      </el-menu-item>
    </el-menu>
</template>



<script setup>
import {House,User,Postcard,SetUp,Stopwatch,Monitor,Guide} from '@element-plus/icons-vue';
import {useRouter} from 'vue-router';
import {onMounted} from 'vue';
import { ElMessage } from 'element-plus';


const genRouterMap = (prefix)=>{
    return {
        "1":`${prefix}`,
        "2":`${prefix}/friend`,
        "3-2":`${prefix}/state-node`,
        "4":`${prefix}/about`,
        "5":`${prefix}/message`,
    }
}

const routerMap =genRouterMap("/admin")
const router = useRouter();

let changePage = (index)=>{
    // console.log("选中信息")
    try{
        let page =routerMap[index];
        router.push(page)
    }catch(err){
        // console.log(err);
        ElMessage.error(err.message)
    }
}


</script>


<style scoped>

</style>
